#ifndef VIDEOROOM_H
#define VIDEOROOM_H
#include <QWidget>

#include "../../image/ImageHandler.h"
#include "../../audio/AudioHandler.h"

namespace Ui {
class Videoroom;
}

class Videoroom : public QWidget
{
    Q_OBJECT

public:
    Videoroom(quint16 roomId, const QList<quint16>& partnerList, QWidget* parent = nullptr);
    ~Videoroom();
    CameraHandler* cameraHandler;
    AudioHandler* getAudio() { return audioHandler; }
    void setAvatarList(const QStringList &imgPaths);
    void init();
    void initUserAvatar();
protected:
    void showEvent(QShowEvent *event) override;
    void setPartnerList();

public slots:
    void onNewFrame(const QImage &img);
    void recvNewFrame(const QImage &img);
    void recvNewText(const QString& text);
    void addPartner(const quint16& userId);
    void delPartner(const quint16& userId);

private slots:
    void on_pushButton_clicked();
    void on_pushButton_send_clicked();
    void on_pushButtonVideo_clicked();
    void onTableCellClicked(int row, int column);

signals:
    void backToMainClicked();
    void textReady(const QString &text); //发送用户输入的消息

private:
    quint16 roomId;
    quint16 chosenUserId;
    QList<quint16> partnerList;
    Ui::Videoroom *ui;
    ImageHandler* imageHandler;
    AudioHandler* audioHandler;
};

#endif // VIDEOROOM_H
